fix(export): images missing in exported Knowledge Base PDF#28
Merged
Rom1-B merged 3 commits intopluginsGLPI:mainfrom May 21, 2025
Merged
fix(export): images missing in exported Knowledge Base PDF#28Rom1-B merged 3 commits intopluginsGLPI:mainfrom
Rom1-B merged 3 commits intopluginsGLPI:mainfrom
Conversation
stonebuzz
approved these changes
Apr 24, 2025
stonebuzz
left a comment
There was a problem hiding this comment.
Seems good, waiting for customers feedback
stonebuzz
requested changes
Apr 25, 2025
Comment on lines
88
to
94
| $width = null; | ||
|
|
||
| $path = '<img src="file://' . GLPI_DOC_DIR . '/' . $docimg->fields['filepath'] . '"/>'; | ||
| if (preg_match('/\bwidth=["\']?(\d+)/i', $img[0], $match_width)) { | ||
| $width = $match_width[1]; | ||
| } | ||
|
|
||
| $path = '<img src="file://' . GLPI_DOC_DIR . '/' . $docimg->fields['filepath'] . '" width="' . $width . '"/>'; |
There was a problem hiding this comment.
perhaps we should take the example of the plugin's ticket.class.php class (which also processes images in the content)
$content = Glpi\Toolbox\Sanitizer::unsanitize(Html::entity_decode_deep($job->fields['content']));
$content = preg_replace('#data:image/[^;]+;base64,#', '@', $content);
preg_match_all('/<img [^>]*src=[\'"]([^\'"]*docid=([0-9]*))[^>]*>/', $content, $res, PREG_SET_ORDER);
Author
There was a problem hiding this comment.
Yes, I took the code from ticket.class.php for image processing. This fixes the problem that prevented the plugin from displaying images but if the image had been resized, it was not taken into account.
Author
|
It's good for customer |
stonebuzz
approved these changes
May 21, 2025
Rom1-B
approved these changes
May 21, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Screenshots (if appropriate):